package com.xxwy.sort;

import com.xxwy.sort.nlogn.HeapSort;
import com.xxwy.sort.nlogn.QuickSort2;
import com.xxwy.sort.nlogn.QuickSort3;

import java.util.Random;

/**
 * @author xxwy
 */
public class Test {


    public static int[] generateRandomArray(int n, int rangeL, int rangeR) {
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            //rand.nextInt(MAX - MIN + 1) + MIN;
            array[i] = new Random().nextInt(rangeR - rangeL + 1) - rangeL;
        }
        return array;
    }

    public static void printArray(int[] arrag){
        System.out.print("[ ");
        for (int i = 0; i < arrag.length; i++) {
            System.out.print( arrag[i] + " ");
        }
        System.out.print("] \n");
    }


    public static void main(String[] args) {
        int n = 20;
        int[] array = generateRandomArray(n, 0, 1000);
        printArray(array);
        new HeapSort().sort(array,n);
        printArray(array);

    }
}
